<script src="/public_html/js/jquery-1.5.1.min.js" type="text/javascript"></script>
<script src="/public_html/js/jquery-ui-1.8.10.custom.min.js" type="text/javascript"></script>

<script type="text/javascript">
jQuery(function(){
    jQuery("#sortable").sortable({
        axis: "y"
        //, revert: true
        , containment: "parent"
        , tolerance: "pointer"
        , update: function(event, ui) {
            jQuery("#idsort").val(jQuery("#sortable").sortable("serialize"));
            }
        });
});
</script>
<?php if( $arFiles ): ?>
    <div id="sortable">
    <?php foreach( $arFiles as $photo):?>
        
        <div id="id_<?php echo $photo->getId()?>" class="sort_product">
            <div class="sort_picture">
                <?php echo image_tag(Files::getDirPath('tiny') . $photo->getUname()
                                    , array(
                                        'alt' => ''
                                        ,'id' => 'sort_picture'
                                    )
                                )?>
            </div>
            <div class="sort_actions">
                <?php echo link_to(
                                image_tag(
                                    'delete.png'
                                    , array(
                                        'alt' => __('Delete')
                                        , 'title' => __('Delete')
                                    )
                                )
                                , 'textmodule/save?id=' . $text_module->getId() . '&uname='  . $photo->getNameForUrl()
                                , array(
                                    'confirm' => __('Are you sure?!')
                                )
                ) ?>
            </div>
        </div>
        
    <?php endforeach; ?>
    </div>
    
    <?php echo input_hidden_tag("idsort", "") ?>
    
<?php endif; ?>
<div style="clear: both;"></div>
<hr />
<div class="center_text">
    <div class="text_item">
        <?php echo __('Add new photo') ?>: 
        <?php echo input_file_tag(
                            'text_module[new_photo]'
                            , array(
                                'class' => 'login_input'
                            )
                        ) ?>
    </div>
</div>
